﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuimini-v2/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
        .input-select {
            position: absolute;
            z-index: 2;
            width: 160px;
            top: 0px;
            display: none;
        }

    </style>
</head>
<body>
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label">费用名称</label>
            <div class="layui-input-inline">
                <input type="text" name="expenseName" placeholder="请输入" value="" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label required">费用类型</label>

            <div class="layui-input-inline">
                <input type="text" name="expenseType" id="expenseType" class="layui-input" style="position:absolute;z-index:2;width:80%;" lay-verify="required" value="111" onkeyup="search()" autocomplete="off">
                <select type="text" id="hc_select" lay-filter="hc_select" autocomplete="off" placeholder="移交单位全称" lay-verify="required" class="layui-select" lay-search>
                    <option value=""></option>
                    @{ foreach (var list in ViewBag.data)
                        {
                            <option value="@list">@list</option>
                        }
                    }
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">费用金额</label>
            <div class="layui-input-inline">
                <input type="text" name="expenseNumber" placeholder="请输入" value="" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">费用所属</label>
            <div class="layui-input-inline">
                <input type="text" name="expenseBelong" placeholder="请输入" value="" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
    <script src="/layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/layuimini-v2/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <script>
        layui.use(['form', 'tableSelect', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            tableSelect = layui.tableSelect,
            $ = layui.$;

            form.on('select(hc_select)', function (data) {   //选择移交单位 赋值给input框
                $("#expenseType").val(data.value);
                $("#hc_select").next().find("dl").css({ "display": "none" });
                form.render();
            });

            window.search = function () {
                var value = $("#expenseType").val();
                $("#hc_select").val(value);
                form.render();
                $("#hc_select").next().find("dl").css({ "display": "block" });
                var dl = $("#hc_select").next().find("dl").children();
                var j = -1;
                for (var i = 0; i < dl.length; i++) {
                    if (dl[i].innerHTML.indexOf(value) <= -1) {
                        dl[i].style.display = "none";
                        j++;
                    }
                    if (j == dl.length - 1) {
                        $("#hc_select").next().find("dl").css({ "display": "none" });
                    }
                }

            }



        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var data = data.field;
            var index = layer.alert("确认信息无误吗", {
                title: '确认'
            }, function () {

				$.ajax({
					url: "@Url.Action("AddExpenseInfo")",
					type: "post",
                    data: { "expenseName": data.expenseName, "expenseType": data.expenseType, "expenseNumber": data.expenseNumber, "expenseBelong": data.expenseBelong, "remark": data.remark },
					success: function (da) {
						console.log(da)
						layer.msg(da.msg)

					},
				})
                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.location.reload();
                parent.layer.close(iframeIndex);

            });



            return false;
        });

    });
    </script>
</body>
</html>